package com.well.register.netty;

import com.well.register.config.PropertiesConfig;
import com.well.register.data.DataCenter;
import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Data
public class RegisterServer {

    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Resource
    private PropertiesConfig propertiesConfig;

    public void run() {
        init();
        RpcServer.run(propertiesConfig);
    }

    public void init() {
        DataCenter.setPort(propertiesConfig.getPort());
        DataCenter.setEnableHeatBeat(propertiesConfig.getHeartBeat());
        DataCenter.setStartTime(System.currentTimeMillis());
    }
}
